package com.rjkj.medicalwaste.adapter

import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.dynamicanimation.animation.DynamicAnimation
import androidx.dynamicanimation.animation.FlingAnimation
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.rjkj.medicalwaste.R
import com.rjkj.medicalwaste.bean.TestBean


class StayPackAdapter:PagingDataAdapter<TestBean, StayPackAdapter.ViewHolder>(COMPARATOR) {
    companion object {
        private val COMPARATOR = object : DiffUtil.ItemCallback<TestBean>() {
            override fun areItemsTheSame(oldItem: TestBean, newItem: TestBean): Boolean {
                return oldItem.name == newItem.name
            }

            override fun areContentsTheSame(oldItem: TestBean, newItem: TestBean): Boolean {
                return oldItem == newItem
            }
        }
    }
    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val weight: TextView = itemView.findViewById(R.id.tv_weight)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val test = getItem(position)
        if (test != null) {
            holder.weight.text = test.name
        }
        holder.itemView.setOnClickListener {

        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(
            R.layout.item_stay_pack,
            parent,
            false
        )
        return ViewHolder(view)
    }
}